﻿#include "DialogPop.h"
#include "GlobalUiStyle.h"
DialogPop::DialogPop(QWidget *parent) : Dialog(parent)
{
    setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
    m_closeButton = new PushButtonTitle(this);
    PushButtonTitle::initButton(m_closeButton,tr(""),258 , 2 , 30 , 30 , styleLButtonTitleClose);
    connect(m_closeButton, SIGNAL(clicked()), this, SLOT(reject()));

    m_OKButton = new PushButtonSystem(this);
    m_OKButton->setObjectName("Func");
    PushButtonSystem::initButton(m_OKButton,tr("确认"),270 , 2 , 60 , 25 , styleLPushButtonGlobal);
    connect(m_OKButton, SIGNAL(clicked()), this, SLOT(accept()));

    m_CancelButton = new PushButtonSystem(this);
    m_CancelButton->setObjectName("Func");
    PushButtonSystem::initButton(m_CancelButton,tr("取消"),270 , 2 , 60 , 25 , styleLPushButtonGlobal);
    connect(m_CancelButton, SIGNAL(clicked()), this, SLOT(reject()));

    m_labelShow = new Label(this);
    m_labelShow->setObjectName("ShowPair");
    Label::initLabel(m_labelShow,"",100,70,100,30,styleLabelText);
    m_labelShow->setAlignment(Qt::AlignCenter);
    this->setStyleSheet(styleWidgetGlobal);
    this->resize(380,100);
}

void DialogPop::hideCancelButton()
{
    m_CancelButton->hide();
}

void DialogPop::setWidget(QWidget *widget)
{
    m_showWidget = widget;
    m_showWidget->move(0,0);
    m_showWidget->show();

    m_closeButton->raise();
}

void DialogPop::setText(QString str)
{
    m_labelShow->setText(str);
}

void DialogPop::showEvent(QShowEvent *event)
{
    m_CancelButton->move(this->width() - 2*m_CancelButton->width() - 20 , this->height() - m_CancelButton->height() - 5);
    m_OKButton->move(this->width() - m_OKButton->width() - 10 , this->height() - m_OKButton->height() - 5);
    m_closeButton->move(this->width() - m_closeButton->width()  ,0);
    m_labelShow->resize(this->width(),30);
    m_labelShow->move(0,(this->height() - m_labelShow->height())/2);
}
